//根据CODE查询部门
export const getDeptByCode = (code) => {
  const deptList = localStorage.getItem('deptList')
    ? JSON.parse(localStorage.getItem('deptList'))
    : []
  let label
  function searchCode(obj) {
    for (const a in obj) {
      if (obj[a].value == code) {
        label = obj[a].label
        return
      }
      if (typeof obj[a] == 'object') searchCode(obj[a])
    }
  }
  searchCode(deptList)
  return label
}

// 根据编码确定查询的部门
export const confirmDeptByCode = (code) => {
  const deptList = localStorage.getItem('deptList')
    ? JSON.parse(localStorage.getItem('deptList'))
    : []
  let result
  function searchCode(obj) {
    for (const a in obj) {
      if (obj[a].value == code) {
        result = obj[a]
        return
      }
      if (typeof obj[a] == 'object') searchCode(obj[a])
    }
  }
  searchCode(deptList)
  return result
}
